export function requset(config: any) {
  const {
    url, // 接口地址
    data, // 请求参数
    method = 'GET', // 请求方法
    showLoading = true, // 是否展示 loading
  } = config;

  return new Promise(async (resolve, reject) => {
    if (showLoading) {
      uni.showLoading({
        title: '加载中',
      });
    }

    uni.request({
      data,
      url,
      header: {
        Authorization: "Bearer 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"
      },
      method,
      success: (res) => {
        resolve(res.data);
      },
      fail: (err) => {
        resolve(err);
      },
      complete() {
        if (showLoading) {
          uni.hideLoading();
        }
      },
    });
  })
}

export const axios = requset